import tableHeight from './directives/tableHeight'
import moment from 'moment'
import { workflowStatus } from '@/utils/dicData'

const install = function(Vue) {
  // 绑定v-adaptive指令
  Vue.directive('tableHeight', tableHeight)

  Vue.filter('date', val => moment(val).format('YYYY-MM-DD'))
  Vue.filter('dateTime', val => moment(val).format('YYYY-MM-DD HH:mm:ss'))

  Vue.filter('formateFlowStatus', val => {
    const findItem = workflowStatus.filter(item => item.value === val)[0]
    return findItem ? findItem.name : ''
  })
}

if (window.Vue) {
  window['tableHeight'] = tableHeight
  // eslint-disable-next-line no-undef
  Vue.use(install)
}

tableHeight.install = install

export default tableHeight
